<template>
  <Navbar :showLeft="false" title="经验分享"></Navbar>
  <view>
    <view class="share-list">
      <DataList
        :dataSource="dataSource"
        @loadData="loadDataList"
        :loadStatus="loadStatus"
      >
        <template #default="{ data }">
          <ShareItem :data="data" :showDetail="showDetail"></ShareItem>
        </template>
      </DataList>
    </view>
  </view>
</template>

<script setup>
import ShareItem from "./ShareItem.vue";
import { onLoad, onShow, onReachBottom } from "@dcloudio/uni-app";
import { ref, reactive, getCurrentInstance, nextTick } from "vue";
const { proxy } = getCurrentInstance();
import { usePageOpStore } from "@/stores/pageOp";
const pageOpStore = usePageOpStore();

const props = defineProps({
  showDetail: {
    type: Boolean,
    defualt: false,
  },
});

const dataSource = ref({});
const loadStatus = ref(null);
const loadDataList = async () => {
  loadStatus.value = "loading";
  let result = await proxy.Request({
    url: proxy.Api.loadShareInfo,
    showLoading: false,
    params: {
      pageNo: dataSource.value.pageNo,
    },
  });
  if (!result) {
    return;
  }
  loadStatus.value = "more";
  dataSource.value = result.data;
};

onShow(() => {
  pageOpStore.setOp(true, true);
});
onLoad(() => {
  loadDataList();
});

onReachBottom(() => {});
</script>

<style>
page {
  background: #f3f3f3;
}
</style>
<style lang="scss" scoped>
.share-list {
  padding: 5px;
}
</style>
